#include <QLabel>
#include <QComboBox>
#include <QGridLayout>
#include <QPushButton>

#include <qwt/qwt_plot_curve.h>
#include "./waveDisplay/displayplot.h"

#include "panel.h"
//#include "reportchart.h"
/*==================================================================
 *    作者：Creater
 *    简介： 标签
 *    主页： unix8.net
 *    日期：2014-04-22
/*==================================================================*/


Panel::Panel(DisplayPlot *dispayWidget_, QWidget *parent ):dispayWidget(dispayWidget_),
    QTabWidget( parent )
{
    setTabPosition( QTabWidget::West );

    addTab( createDisplayTab( this ), tr("显示控制") );
    addTab( createDataProcessTab( this ), tr("生成PDF") );

    connect( d_gridStyle, SIGNAL( currentIndexChanged( int ) ),
             dispayWidget, SLOT( gridChange(int) ) );
}


QWidget *Panel::createDataProcessTab( QWidget *parent )
{
    QWidget *page = new QWidget( parent );
    int row = 0;
    QPushButton* btnPdf = new QPushButton("生成PDF",page);
    btnPdf->setToolTip("生成PDF文件.");
    connect( btnPdf, SIGNAL( clicked()), dispayWidget, SLOT(exportPlot( )));

    QGridLayout *layout = new QGridLayout( page );
    layout->addWidget( btnPdf, row++, 0 );
    layout->setRowStretch( row, 10 );
    return page;
}

QWidget *Panel::createDisplayTab( QWidget *parent )
{
    QWidget *page = new QWidget( parent );

    d_gridStyle = new QComboBox( page );

    d_gridStyle->addItem( "不显网格" );
    d_gridStyle->addItem( "虚线网格" );
    d_gridStyle->addItem( "实线网格" );
    d_gridStyle->addItem( "较大网格" );
    d_gridStyle->addItem( "较小网格" );
    d_gridStyle->setCurrentIndex(4);


    int row = 0;
    QGridLayout *layout = new QGridLayout( page );
    QPushButton* btnClose = new QPushButton("关闭",page);
    btnClose->setToolTip("关闭波形图.");
    //connect( btnClose, SIGNAL( clicked()), page->parent()->parent(), SLOT(close( )));
    connect( btnClose, SIGNAL( clicked()),this->parent(), SLOT(close( )));
    QPushButton* btnEnlarg = new QPushButton("左键放大",page);
    btnEnlarg->setEnabled(false);
    QPushButton* btnEnsmall = new QPushButton("右键单击缩小",page);
    btnEnsmall->setEnabled(false);
    QPushButton* btnMove = new QPushButton("中键按住拖放",page);
    btnMove->setEnabled(false);
    layout->addWidget( btnClose , row++, 0 ,1, 2);
    layout->addWidget( d_gridStyle, row++, 0, 1, 2 );
    layout->addWidget( btnEnlarg , row++, 0 ,1, 2);
    layout->addWidget( btnEnsmall , row++, 0 ,1, 2);
    layout->addWidget( btnMove , row++, 0 ,1, 2);
    layout->setRowStretch( row, 10 );
    return page;
}
